package org.bigdata.framework.core.protocol;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;
import org.bigdata.framework.core.mapper.custom.DynamicMapper;
import org.bigdata.framework.core.model.Classes;
import org.bigdata.framework.core.model.CommonDataProperty;
import org.bigdata.framework.core.model.CommonObjectProperty;
import org.bigdata.framework.core.model.DataBackup;
import org.bigdata.framework.core.model.DataExport;
import org.bigdata.framework.core.model.DataImport;
import org.bigdata.framework.core.model.DataInterface;
import org.bigdata.framework.core.model.DataProperty;
import org.bigdata.framework.core.model.DataRecovery;
import org.bigdata.framework.core.model.DataSource;
import org.bigdata.framework.core.model.DataSubmit;
import org.bigdata.framework.core.model.DataType;
import org.bigdata.framework.core.model.Department;
import org.bigdata.framework.core.model.Dict;
import org.bigdata.framework.core.model.DictItem;
import org.bigdata.framework.core.model.Feedback;
import org.bigdata.framework.core.model.IndexingRules;
import org.bigdata.framework.core.model.IndexingWeights;
import org.bigdata.framework.core.model.Log;
import org.bigdata.framework.core.model.Member;
import org.bigdata.framework.core.model.MemberMessage;
import org.bigdata.framework.core.model.Menu;
import org.bigdata.framework.core.model.MenuButton;
import org.bigdata.framework.core.model.NlpSensitiveWord;
import org.bigdata.framework.core.model.NlpStopWord;
import org.bigdata.framework.core.model.ObjectProperty;
import org.bigdata.framework.core.model.OpenLogin;
import org.bigdata.framework.core.model.Payment;
import org.bigdata.framework.core.model.Permission;
import org.bigdata.framework.core.model.PermissionButton;
import org.bigdata.framework.core.model.PermissionClasses;
import org.bigdata.framework.core.model.RepositoryProduct;
import org.bigdata.framework.core.model.Role;
import org.bigdata.framework.core.model.SearchFavoriteCategory;
import org.bigdata.framework.core.model.SearchFavoriteResource;
import org.bigdata.framework.core.model.SearchHistory;
import org.bigdata.framework.core.model.SearchHotwords;
import org.bigdata.framework.core.model.SearchNotes;
import org.bigdata.framework.core.model.SearchSortRule;
import org.bigdata.framework.core.model.SearchSubscribe;
import org.bigdata.framework.core.model.SearchWeightCustoms;
import org.bigdata.framework.core.model.SearchWeightFields;
import org.bigdata.framework.core.model.ShardingDataSource;
import org.bigdata.framework.core.model.ShardingRepositoryCount;
import org.bigdata.framework.core.model.ShardingRepositoryDataSource;
import org.bigdata.framework.core.model.User;
import org.bigdata.framework.core.model.UserGroup;
import org.bigdata.framework.core.model.UserGroupRole;
import org.bigdata.framework.core.model.UserGroupUser;
import org.bigdata.framework.core.model.UserRole;
import org.bigdata.framework.core.service.IClassesService;
import org.bigdata.framework.core.service.ICommonDataPropertyService;
import org.bigdata.framework.core.service.ICommonObjectPropertyService;
import org.bigdata.framework.core.service.IDataBackupService;
import org.bigdata.framework.core.service.IDataExportService;
import org.bigdata.framework.core.service.IDataImportService;
import org.bigdata.framework.core.service.IDataInterfaceService;
import org.bigdata.framework.core.service.IDataPropertyService;
import org.bigdata.framework.core.service.IDataRecoveryService;
import org.bigdata.framework.core.service.IDataSourceService;
import org.bigdata.framework.core.service.IDataSubmitService;
import org.bigdata.framework.core.service.IDataTypeService;
import org.bigdata.framework.core.service.IDepartmentService;
import org.bigdata.framework.core.service.IDictItemService;
import org.bigdata.framework.core.service.IDictService;
import org.bigdata.framework.core.service.IFeedbackService;
import org.bigdata.framework.core.service.IIndexingRulesService;
import org.bigdata.framework.core.service.IIndexingWeightsService;
import org.bigdata.framework.core.service.ILogService;
import org.bigdata.framework.core.service.IMemberMessageService;
import org.bigdata.framework.core.service.IMemberService;
import org.bigdata.framework.core.service.IMenuButtonService;
import org.bigdata.framework.core.service.IMenuService;
import org.bigdata.framework.core.service.INlpSensitiveWordService;
import org.bigdata.framework.core.service.INlpStopWordService;
import org.bigdata.framework.core.service.IObjectPropertyService;
import org.bigdata.framework.core.service.IOpenLoginService;
import org.bigdata.framework.core.service.IPaymentService;
import org.bigdata.framework.core.service.IPermissionButtonService;
import org.bigdata.framework.core.service.IPermissionClassesService;
import org.bigdata.framework.core.service.IPermissionService;
import org.bigdata.framework.core.service.IRepositoryProductService;
import org.bigdata.framework.core.service.IRoleService;
import org.bigdata.framework.core.service.ISearchFavoriteCategoryService;
import org.bigdata.framework.core.service.ISearchFavoriteResourceService;
import org.bigdata.framework.core.service.ISearchHistoryService;
import org.bigdata.framework.core.service.ISearchHotwordsService;
import org.bigdata.framework.core.service.ISearchNotesService;
import org.bigdata.framework.core.service.ISearchSortRuleService;
import org.bigdata.framework.core.service.ISearchSubscribeService;
import org.bigdata.framework.core.service.ISearchWeightCustomsService;
import org.bigdata.framework.core.service.ISearchWeightFieldsService;
import org.bigdata.framework.core.service.IShardingDataSourceService;
import org.bigdata.framework.core.service.IShardingRepositoryCountService;
import org.bigdata.framework.core.service.IShardingRepositoryDataSourceService;
import org.bigdata.framework.core.service.IUserGroupRoleService;
import org.bigdata.framework.core.service.IUserGroupService;
import org.bigdata.framework.core.service.IUserGroupUserService;
import org.bigdata.framework.core.service.IUserRoleService;
import org.bigdata.framework.core.service.IUserService;
import org.bigdata.framework.core.utils.DBUtils;
import org.bigdata.framework.core.utils.SQLAdapter;
import org.bigdata.framework.core.utils.SettingUtil;
import org.springframework.beans.factory.annotation.Autowired;

import com.xxl.conf.core.XxlConfClient;

public class BaseService implements IBaseService {

	private static final Logger LOG = Logger.getLogger(BaseService.class);

	@Autowired
	private IUserService userService;
	@Autowired
	private IUserRoleService userRoleService;
	@Autowired
	private IRoleService roleService;
	@Autowired
	private IDepartmentService departmentService;
	@Autowired
	private IMenuService menuService;
	@Autowired
	private IMenuButtonService menuButtonService;
	@Autowired
	private IUserGroupService userGroupService;
	@Autowired
	private IUserGroupRoleService userGroupRoleService;
	@Autowired
	private IUserGroupUserService userGroupUserService;
	@Autowired
	private IPermissionService permissionService;
	@Autowired
	private IPermissionButtonService permissionButtonService;
	@Autowired
	private IPermissionClassesService permissionClassesService;
	@Autowired
	private IDataTypeService dataTypeService;
	@Autowired
	private IDictService dictService;
	@Autowired
	private IDictItemService dictItemService;
	@Autowired
	private ICommonDataPropertyService commonDataPropertyService;
	@Autowired
	private ICommonObjectPropertyService commonObjectPropertyService;
	@Autowired
	private IClassesService classesService;
	@Autowired
	private IDataPropertyService dataPropertyService;
	@Autowired
	private IObjectPropertyService objectPropertyService;
	@Autowired
	private IDataSourceService dataSourceService;
	@Autowired
	private IDataImportService dataImportService;
	@Autowired
	private IDataExportService dataExportService;
	@Autowired
	private IDataInterfaceService dataInterfaceService;
	@Autowired
	private IDataSubmitService dataSubmitService;
	@Autowired
	private ILogService logService;
	@Autowired
	private IMemberService memberService;
	@Autowired
	private IOpenLoginService openLoginService;
	@Autowired
	private IPaymentService paymentService;
	@Autowired
	private IRepositoryProductService repositoryProductService;
	@Autowired
	private DynamicMapper dynamicMapper;
	@Autowired
	private PublicService publicService;
	@Autowired
	private ISearchSortRuleService searchSortRuleService;
	@Autowired
	private ISearchWeightCustomsService searchWeightCustomsService;
	@Autowired
	private ISearchWeightFieldsService searchWeightFieldsService;
	@Autowired
	private ISearchHotwordsService searchHotwordsService;
	@Autowired
	private ISearchHistoryService searchHistoryService;
	@Autowired
	private ISearchNotesService searchNotesService;
	@Autowired
	private IIndexingRulesService indexingRulesService;
	@Autowired
	private IIndexingWeightsService indexingWeightsService;
	@Autowired
	private INlpSensitiveWordService nlpSensitiveWordService;
	@Autowired
	private INlpStopWordService nlpStopWordService;
	@Autowired
	private ISearchSubscribeService searchSubscribeService;
	@Autowired
	private IDataBackupService dataBackupService;
	@Autowired
	private IDataRecoveryService dataRecoveryService;
	@Autowired
	private IShardingDataSourceService shardingDataSourceService;
	@Autowired
	private IShardingRepositoryCountService shardingRepositoryCountService;
	@Autowired
	private IShardingRepositoryDataSourceService shardingRepositoryDataSourceService;
	@Autowired
	private IMemberMessageService memberMessageService;
	@Autowired
	private ISearchFavoriteCategoryService searchFavoriteCategoryService;
	@Autowired
	private ISearchFavoriteResourceService searchFavoriteResourceService;
	@Autowired
	private IFeedbackService feedbackService;
	
	
	
	
	// 数据库类型
	private String dbStyle = XxlConfClient.get("dal.db.style", "mysql");
	// 知识库前缀
	private String repositoryPrefix = XxlConfClient.get(
			"dal.repository.prefix", "hymax");

	SQLAdapter aSQLAdapter = null;

	@Override
	public User saveUser(User user) {
		boolean r = userService.insert(user);
		if (r) {
			return user;
		}
		return null;
	}

	@Override
	public User editUser(User user) {
		boolean r = userService.updateAllColumnById(user);
		if (r) {
			return user;
		}
		return null;
	}

	@Override
	public void deleteUser(User user) {
		boolean r = userService.deleteById(user.getId());
		if (r) {
			System.out.println("user 删除成功>>>" + user.getId());
		}

	}

	@Override
	public Role saveRole(Role role) {
		boolean r = roleService.insert(role);
		if (r) {
			return role;
		}
		return null;
	}

	@Override
	public Role editRole(Role role) {
		boolean r = roleService.updateAllColumnById(role);
		if (r) {
			return role;
		}
		return null;
	}

	@Override
	public void deleteRole(Role role) {
		boolean r = roleService.deleteById(role.getId());
		if (r) {
			System.out.println("role 删除成功>>>" + role.getId());
		}

	}

	@Override
	public Department saveDepartment(Department department) {

		boolean r = departmentService.insert(department);
		if (r) {
			return department;
		}
		return null;
	}

	@Override
	public Department editDepartment(Department department) {
		boolean r = departmentService.updateAllColumnById(department);
		if (r) {
			return department;
		}
		return null;
	}

	@Override
	public void deleteDepartment(Department department) {
		boolean r = departmentService.deleteById(department.getId());
		if (r) {
			System.out.println("department 删除成功>>>" + department.getId());
		}

	}

	@Override
	public Menu saveMenu(Menu menu) {
		boolean r = menuService.insert(menu);
		if (r) {
			return menu;
		}
		return null;
	}

	@Override
	public Menu editMenu(Menu menu) {
		boolean r = menuService.updateAllColumnById(menu);
		if (r) {
			return menu;
		}
		return null;
	}

	@Override
	public void deleteMenu(Menu menu) {
		boolean r = menuService.deleteById(menu.getId());
		if (r) {
			System.out.println("menu 删除成功>>>" + menu.getId());
		}

	}

	@Override
	public MenuButton saveMenuButton(MenuButton menuButton) {
		boolean r = menuButtonService.insert(menuButton);
		if (r) {
			return menuButton;
		}
		return null;
	}

	@Override
	public MenuButton editMenuButton(MenuButton menuButton) {
		boolean r = menuButtonService.updateAllColumnById(menuButton);
		if (r) {
			return menuButton;
		}
		return null;
	}

	@Override
	public void deleteMenuButton(MenuButton menuButton) {
		boolean r = menuButtonService.deleteById(menuButton.getId());
		if (r) {
			System.out.println("menuButton 删除成功>>>" + menuButton.getId());
		}

	}

	@Override
	public UserGroup saveUserGroup(UserGroup userGroup) {

		boolean r = userGroupService.insert(userGroup);
		if (r) {
			return userGroup;
		}
		return null;
	}

	@Override
	public UserGroup editUserGroup(UserGroup userGroup) {

		boolean r = userGroupService.updateAllColumnById(userGroup);
		if (r) {
			return userGroup;
		}
		return null;
	}

	@Override
	public void deleteUserGroup(UserGroup userGroup) {

		boolean r = userGroupService.deleteById(userGroup.getId());
		if (r) {
			System.out.println("userGroup 删除成功>>>" + userGroup.getId());
		}

	}

	@Override
	public UserGroupRole saveUserGroupRole(UserGroupRole userGroupRole) {

		boolean r = userGroupRoleService.insert(userGroupRole);
		if (r) {
			return userGroupRole;
		}
		return null;
	}

	@Override
	public UserGroupRole editUserGroup(UserGroupRole userGroupRole) {

		boolean r = userGroupRoleService.updateAllColumnById(userGroupRole);
		if (r) {
			return userGroupRole;
		}
		return null;
	}

	@Override
	public void deleteUserGroupRole(UserGroupRole userGroupRole) {

		boolean r = userGroupRoleService.deleteById(userGroupRole.getId());
		if (r) {
			System.out.println("userGroupRole 删除成功>>>" + userGroupRole.getId());
		}

	}

	@Override
	public UserRole saveUserRole(UserRole userRole) {

		boolean r = userRoleService.insert(userRole);
		if (r) {
			return userRole;
		}
		return null;
	}

	@Override
	public UserRole editUserRole(UserRole userRole) {

		boolean r = userRoleService.updateAllColumnById(userRole);
		if (r) {
			return userRole;
		}
		return null;
	}

	@Override
	public void deleteUserRole(UserRole userRole) {

		boolean r = userRoleService.deleteById(userRole.getId());
		if (r) {
			System.out.println("userRole 删除成功>>>" + userRole.getId());
		}

	}

	@Override
	public UserGroupUser saveUserGroupUser(UserGroupUser userGroupUser) {

		boolean r = userGroupUserService.insert(userGroupUser);
		if (r) {
			return userGroupUser;
		}
		return null;
	}

	@Override
	public UserGroupUser editUserGroupUser(UserGroupUser userGroupUser) {

		boolean r = userGroupUserService.updateAllColumnById(userGroupUser);
		if (r) {
			return userGroupUser;
		}
		return null;
	}

	@Override
	public void deleteUserGroupUser(UserGroupUser userGroupUser) {

		boolean r = userGroupUserService.deleteById(userGroupUser.getId());
		if (r) {
			System.out.println("userGroupUser 删除成功>>>" + userGroupUser.getId());
		}

	}

	@Override
	public Permission savePermission(Permission permission) {

		boolean r = permissionService.insert(permission);
		if (r) {
			return permission;
		}
		return null;
	}

	@Override
	public Permission editPermission(Permission permission) {

		boolean r = permissionService.updateAllColumnById(permission);
		if (r) {
			return permission;
		}
		return null;
	}

	@Override
	public void deletePermission(Permission permission) {

		boolean r = permissionService.deleteById(permission.getId());
		if (r) {
			System.out.println("permission 删除成功>>>" + permission.getId());
		}

	}

	@Override
	public PermissionButton savePermissionButton(
			PermissionButton permissionButton) {

		boolean r = permissionButtonService.insert(permissionButton);
		if (r) {
			return permissionButton;
		}
		return null;
	}

	@Override
	public PermissionButton editPermissionButton(
			PermissionButton permissionButton) {

		boolean r = permissionButtonService
				.updateAllColumnById(permissionButton);
		if (r) {
			return permissionButton;
		}
		return null;
	}

	@Override
	public void deletePermissionButton(PermissionButton permissionButton) {

		boolean r = permissionButtonService
				.deleteById(permissionButton.getId());
		if (r) {
			System.out.println("permissionButton 删除成功>>>"
					+ permissionButton.getId());
		}

	}

	@Override
	public PermissionClasses savePermissionClasses(
			PermissionClasses permissionClasses) {

		boolean r = permissionClassesService.insert(permissionClasses);
		if (r) {
			return permissionClasses;
		}
		return null;
	}

	@Override
	public PermissionClasses editPermissionClasses(
			PermissionClasses permissionClasses) {

		boolean r = permissionClassesService
				.updateAllColumnById(permissionClasses);
		if (r) {
			return permissionClasses;
		}
		return null;
	}

	@Override
	public void deletePermissionClasses(PermissionClasses permissionClasses) {

		boolean r = permissionClassesService.deleteById(permissionClasses
				.getId());
		if (r) {
			System.out.println("permissionClasses 删除成功>>>"
					+ permissionClasses.getId());
		}

	}

	@Override
	public DataType saveDataType(DataType dataType) {

		boolean r = dataTypeService.insert(dataType);
		if (r) {
			return dataType;
		}
		return null;
	}

	@Override
	public DataType editDataType(DataType dataType) {

		boolean r = dataTypeService.updateAllColumnById(dataType);
		if (r) {
			return dataType;
		}
		return null;
	}

	@Override
	public void deleteDataType(DataType dataType) {

		boolean r = dataTypeService.deleteById(dataType.getId());
		if (r) {
			System.out.println("dataType 删除成功>>>" + dataType.getId());
		}

	}

	@Override
	public Dict saveDict(Dict dict) {

		boolean r = dictService.insert(dict);
		if (r) {
			return dict;
		}
		return null;
	}

	@Override
	public Dict editDict(Dict dict) {

		boolean r = dictService.updateAllColumnById(dict);
		if (r) {
			return dict;
		}
		return null;
	}

	@Override
	public void deleteDict(Dict dict) {

		boolean r = dictService.deleteById(dict.getId());
		if (r) {
			System.out.println("dict 删除成功>>>" + dict.getId());
		}
	}

	@Override
	public DictItem saveDictItem(DictItem dictItem) {

		boolean r = dictItemService.insert(dictItem);
		if (r) {
			return dictItem;
		}
		return null;
	}

	@Override
	public DictItem editDictItem(DictItem dictItem) {

		boolean r = dictItemService.updateAllColumnById(dictItem);
		if (r) {
			return dictItem;
		}
		return null;
	}

	@Override
	public void deleteDictItem(DictItem dictItem) {

		boolean r = dictItemService.deleteById(dictItem.getId());
		if (r) {
			System.out.println("dictItem 删除成功>>>" + dictItem.getId());
		}
	}

	@Override
	public CommonDataProperty saveCommonDataProperty(
			CommonDataProperty commonDataProperty) {

		boolean r = commonDataPropertyService.insert(commonDataProperty);
		if (r) {
			return commonDataProperty;
		}
		return null;
	}

	@Override
	public CommonDataProperty editCommonDataProperty(
			CommonDataProperty commonDataProperty) {

		boolean r = commonDataPropertyService
				.updateAllColumnById(commonDataProperty);
		if (r) {
			return commonDataProperty;
		}
		return null;
	}

	@Override
	public void deleteCommonDataProperty(CommonDataProperty commonDataProperty) {

		boolean r = commonDataPropertyService.deleteById(commonDataProperty
				.getId());
		if (r) {
			System.out.println("commonDataProperty 删除成功>>>"
					+ commonDataProperty.getId());
		}

	}

	@Override
	public CommonObjectProperty saveCommonObjectProperty(
			CommonObjectProperty commonObjectProperty) {

		boolean r = commonObjectPropertyService.insert(commonObjectProperty);
		if (r) {
			return commonObjectProperty;
		}
		return null;
	}

	@Override
	public CommonObjectProperty editCommonObjectProperty(
			CommonObjectProperty commonObjectProperty) {

		boolean r = commonObjectPropertyService
				.updateAllColumnById(commonObjectProperty);
		if (r) {
			return commonObjectProperty;
		}
		return null;
	}

	@Override
	public void deleteCommonObjectProperty(
			CommonObjectProperty commonObjectProperty) {

		boolean r = commonObjectPropertyService.deleteById(commonObjectProperty
				.getId());
		if (r) {
			System.out.println("commonObjectProperty 删除成功>>>"
					+ commonObjectProperty.getId());
		}
	}

	@Override
	public Classes saveClasses(Classes classes) {
		boolean r = classesService.insert(classes);
		if (r) {
			// 创建数据库表
			String sql = DBUtils.createTable(dbStyle, repositoryPrefix + "_"
					+ classes.getNameEn());
			System.out.println("知识库创建表SQL:" + sql);
			aSQLAdapter = new SQLAdapter();
			aSQLAdapter.setSql(sql);
			int dm = dynamicMapper.executeSQL(aSQLAdapter);
			System.out.println("执行sql返回结果集:" + dm);

			return classes;
		}

		return null;
	}

	@Override
	public Classes editClasses(Classes classes) {

		boolean r = classesService.updateAllColumnById(classes);
		if (r) {
			return classes;
		}
		return null;
	}

	@Override
	public void deleteClasses(Classes classes) {

		// 删除自动创建表
		String sql = DBUtils.deleteTable(dbStyle, repositoryPrefix + "_"
				+ classes.getNameEn());
		aSQLAdapter = new SQLAdapter();
		aSQLAdapter.setSql(sql);
		int dm = dynamicMapper.executeSQL(aSQLAdapter);
		System.out.println("执行sql返回结果集:" + dm);

		boolean r = classesService.deleteById(classes.getId());
		if (r) {
			System.out.println("classes 删除成功>>>" + classes.getId());
		}

	}

	@Override
	public DataProperty saveDataProperty(DataProperty dataProperty) {

		// 新增动态表字段
		DataType aDataType = publicService.findDataType(dataProperty
				.getDataTypeId());
		Classes aClasses = publicService.findClasses(dataProperty
				.getClassesId());
		HashMap<String, String> fields = new HashMap<String, String>();
		fields.put(dataProperty.getNameEn(), aDataType.getFieldType() + "/"
				+ dataProperty.getFieldLength().intValue());

		// 判断是否开启分库分表
		HashMap<String, Object> queryParams = new HashMap<>();
		queryParams.put("=,classesEn", aClasses.getNameEn());
		List<ShardingRepositoryCount> srcList = publicService
				.getShardingRepositoryCount(queryParams, 1, 500);
		if (srcList.size() > 0) {
			for (int i = 0; i < srcList.size(); i++) {
				ShardingRepositoryCount aShardingRepositoryCount = srcList
						.get(i);

				// 数据源
				ShardingDataSource aShardingDataSource = publicService
						.findShardingDataSource(aShardingRepositoryCount
								.getShardingDataSourceId());
				// 更新表sql
				String sql = DBUtils.updateName(dbStyle,
						aShardingRepositoryCount.getTableName(), "add", fields);
				System.out.println("新增字段SQL:" + sql);

				// 执行sql语句
				Connection conn = null;
				PreparedStatement ps = null;
				ResultSet rs = null;

				try {
					conn = DriverManager.getConnection(
							aShardingDataSource.getDbUrl(),
							aShardingDataSource.getDbUser(),
							aShardingDataSource.getDbPassword());

					ps = conn.prepareStatement(sql);
					ps.execute(sql);

				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					// 关闭
					if (rs != null)
						try {
							rs.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (ps != null)
						try {
							ps.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (conn != null)
						try {
							conn.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					rs = null;
					ps = null;
					conn = null;
				}
				//
			}
		} else {
			// 新增字段
			String sql = DBUtils.updateName(dbStyle, repositoryPrefix + "_"
					+ aClasses.getNameEn(), "add", fields);
			System.out.println("新增字段SQL:" + sql);
			aSQLAdapter = new SQLAdapter();
			aSQLAdapter.setSql(sql);
			int dm = dynamicMapper.executeSQL(aSQLAdapter);
			System.out.println("执行sql返回结果集:" + dm);
		}

		boolean r = dataPropertyService.insert(dataProperty);
		if (r) {
			return dataProperty;
		}
		return null;
	}

	@Override
	public DataProperty editDataProperty(DataProperty dataProperty) {

		boolean r = dataPropertyService.updateAllColumnById(dataProperty);
		if (r) {
			return dataProperty;
		}
		return null;
	}

	@Override
	public void deleteDataProperty(DataProperty dataProperty) {

		DataType aDataType = publicService.findDataType(dataProperty
				.getDataTypeId());
		Classes aClasses = publicService.findClasses(dataProperty
				.getClassesId());
		// 删除数据库表字段
		HashMap<String, String> fields = new HashMap<String, String>();
		fields.put(dataProperty.getNameEn(), aDataType.getFieldType() + "/"
				+ dataProperty.getFieldLength());

		// 判断是否开启分库分表
		HashMap<String, Object> queryParams = new HashMap<>();
		queryParams.put("=,classesEn", aClasses.getNameEn());
		List<ShardingRepositoryCount> srcList = publicService
				.getShardingRepositoryCount(queryParams, 1, 500);
		if (srcList.size() > 0) {
			for (int i = 0; i < srcList.size(); i++) {
				ShardingRepositoryCount aShardingRepositoryCount = srcList
						.get(i);

				// 数据源
				ShardingDataSource aShardingDataSource = publicService
						.findShardingDataSource(aShardingRepositoryCount
								.getShardingDataSourceId());
				// 更新表sql
				String sql = DBUtils.updateName(dbStyle,
						aShardingRepositoryCount.getTableName(), "delete",
						fields);
				System.out.println("新增字段SQL:" + sql);

				// 执行sql语句
				Connection conn = null;
				PreparedStatement ps = null;
				ResultSet rs = null;

				try {
					conn = DriverManager.getConnection(
							aShardingDataSource.getDbUrl(),
							aShardingDataSource.getDbUser(),
							aShardingDataSource.getDbPassword());

					ps = conn.prepareStatement(sql);
					ps.execute(sql);

				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					// 关闭
					if (rs != null)
						try {
							rs.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (ps != null)
						try {
							ps.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (conn != null)
						try {
							conn.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					rs = null;
					ps = null;
					conn = null;
				}
				//
			}
		} else {
			// 删除字段
			String sql = DBUtils.updateName(dbStyle, repositoryPrefix + "_"
					+ aClasses.getNameEn(), "delete", fields);
			aSQLAdapter = new SQLAdapter();
			aSQLAdapter.setSql(sql);
			int dm = dynamicMapper.executeSQL(aSQLAdapter);
			System.out.println("执行sql返回结果集:" + dm);
		}

		boolean r = dataPropertyService.deleteById(dataProperty.getId());
		if (r) {
			System.out.println("dataProperty 删除成功>>>" + dataProperty.getId());
		}
	}

	@Override
	public ObjectProperty saveObjectProperty(ObjectProperty objectProperty) {

		// 创建关系表（所属类ID）
		Classes aClasses = publicService.findClasses(objectProperty
				.getClassesId());

		// 判断是否开启分库分表
		HashMap<String, Object> queryParams = new HashMap<>();
		queryParams.put("=,classesEn", aClasses.getNameEn());
		List<ShardingRepositoryCount> srcList = publicService
				.getShardingRepositoryCount(queryParams, 1, 500);
		if (srcList.size() > 0) {
			for (int i = 0; i < srcList.size(); i++) {
				ShardingRepositoryCount aShardingRepositoryCount = srcList
						.get(i);
				// 数据源
				ShardingDataSource aShardingDataSource = publicService
						.findShardingDataSource(aShardingRepositoryCount
								.getShardingDataSourceId());
				String sql = DBUtils.createOpTable(dbStyle,
						aShardingRepositoryCount.getTableName() + "_"
								+ objectProperty.getNameEn());

				// 执行sql语句
				Connection conn = null;
				PreparedStatement ps = null;
				ResultSet rs = null;

				try {
					conn = DriverManager.getConnection(
							aShardingDataSource.getDbUrl(),
							aShardingDataSource.getDbUser(),
							aShardingDataSource.getDbPassword());

					ps = conn.prepareStatement(sql);
					ps.execute(sql);

				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					// 关闭
					if (rs != null)
						try {
							rs.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (ps != null)
						try {
							ps.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (conn != null)
						try {
							conn.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					rs = null;
					ps = null;
					conn = null;
				}
				//
			}
		} else {
			String sql = DBUtils.createOpTable(dbStyle, repositoryPrefix + "_"
					+ aClasses.getNameEn() + "_" + objectProperty.getNameEn());

			System.out.println("创建关系表SQL=" + sql);
			aSQLAdapter = new SQLAdapter();
			aSQLAdapter.setSql(sql);
			int dm = dynamicMapper.executeSQL(aSQLAdapter);
			System.out.println("执行sql返回结果集:" + dm);
		}

		boolean r = objectPropertyService.insert(objectProperty);
		if (r) {
			return objectProperty;
		}
		return null;
	}

	@Override
	public ObjectProperty editObjectProperty(ObjectProperty objectProperty) {

		boolean r = objectPropertyService.updateAllColumnById(objectProperty);
		if (r) {
			return objectProperty;
		}
		return null;
	}

	@Override
	public void deleteObjectProperty(ObjectProperty objectProperty) {
		// 删除自动创建表
		Classes aClasses = publicService.findClasses(objectProperty
				.getClassesId());

		// 判断是否开启分库分表
		HashMap<String, Object> queryParams = new HashMap<>();
		queryParams.put("=,classesEn", aClasses.getNameEn());
		List<ShardingRepositoryCount> srcList = publicService
				.getShardingRepositoryCount(queryParams, 1, 500);
		if (srcList.size() > 0) {
			for (int i = 0; i < srcList.size(); i++) {
				ShardingRepositoryCount aShardingRepositoryCount = srcList
						.get(i);
				// 数据源
				ShardingDataSource aShardingDataSource = publicService
						.findShardingDataSource(aShardingRepositoryCount
								.getShardingDataSourceId());
				String sql = DBUtils.deleteTable(dbStyle,
						aShardingRepositoryCount.getTableName() + "_"
								+ objectProperty.getNameEn());
				
				// 执行sql语句
				Connection conn = null;
				PreparedStatement ps = null;
				ResultSet rs = null;
				try {
					conn = DriverManager.getConnection(
							aShardingDataSource.getDbUrl(),
							aShardingDataSource.getDbUser(),
							aShardingDataSource.getDbPassword());
					ps = conn.prepareStatement(sql);
					ps.execute(sql);
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					// 关闭
					if (rs != null)
						try {
							rs.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (ps != null)
						try {
							ps.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					if (conn != null)
						try {
							conn.close();
						} catch (SQLException e) {
							e.printStackTrace();
						}
					rs = null;
					ps = null;
					conn = null;
				}
				//
			}
		} else {
			String sql = DBUtils.deleteTable(dbStyle, repositoryPrefix + "_"
					+ aClasses.getNameEn() + "_" + objectProperty.getNameEn());
			aSQLAdapter = new SQLAdapter();
			aSQLAdapter.setSql(sql);
			int dm = dynamicMapper.executeSQL(aSQLAdapter);
			System.out.println("执行sql返回结果集:" + dm);
		}

		boolean r = objectPropertyService.deleteById(objectProperty.getId());
		if (r) {
			System.out.println("objectProperty 删除成功>>>"
					+ objectProperty.getId());
		}

	}

	@Override
	public DataSource saveDataSource(DataSource dataSource) {

		boolean r = dataSourceService.insert(dataSource);
		if (r) {
			return dataSource;
		}
		return null;
	}

	@Override
	public DataSource editDataSource(DataSource dataSource) {

		boolean r = dataSourceService.updateAllColumnById(dataSource);
		if (r) {
			return dataSource;
		}
		return null;
	}

	@Override
	public void deleteDataSource(DataSource dataSource) {

		boolean r = dataSourceService.deleteById(dataSource.getId());
		if (r) {
			System.out.println("dataSource 删除成功>>>" + dataSource.getId());
		}

	}

	@Override
	public DataImport saveDataImport(DataImport dataImport) {

		boolean r = dataImportService.insert(dataImport);
		if (r) {
			return dataImport;
		}
		return null;
	}

	@Override
	public DataImport editDataImport(DataImport dataImport) {

		boolean r = dataImportService.updateAllColumnById(dataImport);
		if (r) {
			return dataImport;
		}
		return null;
	}

	@Override
	public void deleteDataImport(DataImport dataImport) {

		boolean r = dataImportService.deleteById(dataImport.getId());
		if (r) {
			System.out.println("dataImport 删除成功>>>" + dataImport.getId());
		}
	}

	@Override
	public DataExport saveDataExport(DataExport dataExport) {

		boolean r = dataExportService.insert(dataExport);
		if (r) {
			return dataExport;
		}
		return null;
	}

	@Override
	public DataExport editDataExport(DataExport dataExport) {

		boolean r = dataExportService.updateAllColumnById(dataExport);
		if (r) {
			return dataExport;
		}
		return null;
	}

	@Override
	public void deleteDataExport(DataExport dataExport) {

		boolean r = dataExportService.deleteById(dataExport.getId());
		if (r) {
			System.out.println("dataExport 删除成功>>>" + dataExport.getId());
		}

	}

	@Override
	public DataInterface saveDataInterface(DataInterface dataInterface) {

		boolean r = dataInterfaceService.insert(dataInterface);
		if (r) {
			return dataInterface;
		}
		return null;
	}

	@Override
	public DataInterface editDataInterface(DataInterface dataInterface) {

		boolean r = dataInterfaceService.updateAllColumnById(dataInterface);
		if (r) {
			return dataInterface;
		}
		return null;
	}

	@Override
	public void deleteDataInterface(DataInterface dataInterface) {

		boolean r = dataInterfaceService.deleteById(dataInterface.getId());
		if (r) {
			System.out.println("dataInterface 删除成功>>>" + dataInterface.getId());
		}

	}

	@Override
	public DataSubmit saveDataSubmit(DataSubmit dataSubmit) {

		boolean r = dataSubmitService.insert(dataSubmit);
		if (r) {
			return dataSubmit;
		}
		return null;
	}

	@Override
	public DataSubmit editDataSubmit(DataSubmit dataSubmit) {

		boolean r = dataSubmitService.updateAllColumnById(dataSubmit);
		if (r) {
			return dataSubmit;
		}
		return null;
	}

	@Override
	public void deleteDataSubmit(DataSubmit dataSubmit) {

		boolean r = dataSubmitService.deleteById(dataSubmit.getId());
		if (r) {
			System.out.println("dataSubmit 删除成功>>>" + dataSubmit.getId());
		}
	}

	@Override
	public Log saveLog(Log log) {

		boolean r = logService.insert(log);
		if (r) {
			return log;
		}
		return null;
	}

	@Override
	public Log editLog(Log log) {

		boolean r = logService.updateAllColumnById(log);
		if (r) {
			return log;
		}
		return null;
	}

	@Override
	public void deleteLog(Log log) {

		boolean r = logService.deleteById(log.getId());
		if (r) {
			System.out.println("log 删除成功>>>" + log.getId());
		}
	}

	@Override
	public Member saveMember(Member member) {

		boolean r = memberService.insert(member);
		if (r) {
			return member;
		}
		return null;
	}

	@Override
	public Member editMember(Member member) {

		boolean r = memberService.updateAllColumnById(member);
		if (r) {
			return member;
		}
		return null;
	}

	@Override
	public void deleteMember(Member member) {

		boolean r = memberService.deleteById(member.getId());
		if (r) {
			System.out.println("member 删除成功>>>" + member.getId());
		}
	}

	@Override
	public OpenLogin saveOpenLogin(OpenLogin openLogin) {

		boolean r = openLoginService.insert(openLogin);
		if (r) {
			return openLogin;
		}
		return null;
	}

	@Override
	public OpenLogin editOpenLogin(OpenLogin openLogin) {

		boolean r = openLoginService.updateAllColumnById(openLogin);
		if (r) {
			return openLogin;
		}
		return null;
	}

	@Override
	public void deleteOpenLogin(OpenLogin openLogin) {

		boolean r = openLoginService.deleteById(openLogin.getId());
		if (r) {
			System.out.println("dictId 删除成功>>>" + openLogin.getId());
		}

	}

	@Override
	public Payment savePayment(Payment payment) {

		boolean r = paymentService.insert(payment);
		if (r) {
			return payment;
		}
		return null;
	}

	@Override
	public Payment editPayment(Payment payment) {

		boolean r = paymentService.updateAllColumnById(payment);
		if (r) {
			return payment;
		}
		return null;
	}

	@Override
	public void deletePayment(Payment payment) {

		boolean r = paymentService.deleteById(payment.getId());
		if (r) {
			System.out.println("payment 删除成功>>>" + payment.getId());
		}
	}

	@Override
	public RepositoryProduct saveRepositoryProduct(
			RepositoryProduct repositoryProduct) {

		boolean r = repositoryProductService.insert(repositoryProduct);
		if (r) {
			return repositoryProduct;
		}
		return null;
	}

	@Override
	public RepositoryProduct editRepositoryProduct(
			RepositoryProduct repositoryProduct) {

		boolean r = repositoryProductService
				.updateAllColumnById(repositoryProduct);
		if (r) {
			return repositoryProduct;
		}
		return null;
	}

	@Override
	public void deleteRepositoryProduct(RepositoryProduct repositoryProduct) {

		boolean r = repositoryProductService.deleteById(repositoryProduct
				.getId());
		if (r) {
			System.out.println("repositoryProduct 删除成功>>>"
					+ repositoryProduct.getId());
		}

	}

	@Override
	public SearchSortRule saveSearchSortRule(SearchSortRule searchSortRule) {

		boolean r = searchSortRuleService.insert(searchSortRule);
		if (r) {
			return searchSortRule;
		}
		return null;
	}

	@Override
	public SearchSortRule editSearchSortRule(SearchSortRule searchSortRule) {
		boolean r = searchSortRuleService.updateById(searchSortRule);
		if (r) {
			return searchSortRule;
		}
		return null;
	}

	@Override
	public void deleteSearchSortRule(SearchSortRule searchSortRule) {
		boolean r = searchSortRuleService.deleteById(searchSortRule.getId());
		if (r) {
			System.out.println("searchSortRule 删除成功>>>"
					+ searchSortRule.getId());
		}
	}

	@Override
	public SearchWeightCustoms saveSearchWeightCustoms(
			SearchWeightCustoms searchWeightCustoms) {
		boolean r = searchWeightCustomsService.insert(searchWeightCustoms);
		if (r) {
			return searchWeightCustoms;
		}
		return null;
	}

	@Override
	public SearchWeightCustoms editSearchWeightCustoms(
			SearchWeightCustoms searchWeightCustoms) {
		boolean r = searchWeightCustomsService.updateById(searchWeightCustoms);
		if (r) {
			return searchWeightCustoms;
		}
		return null;
	}

	@Override
	public void deleteSearchWeightCustoms(
			SearchWeightCustoms searchWeightCustoms) {
		boolean r = searchWeightCustomsService.deleteById(searchWeightCustoms
				.getId());
		if (r) {
			System.out.println("searchWeightCustoms 删除成功>>>"
					+ searchWeightCustoms.getId());
		}

	}

	@Override
	public SearchWeightFields saveSearchWeightFields(
			SearchWeightFields searchWeightFields) {
		boolean r = searchWeightFieldsService.insert(searchWeightFields);
		if (r) {
			return searchWeightFields;
		}
		return null;
	}

	@Override
	public SearchWeightFields editSearchWeightFields(
			SearchWeightFields searchWeightFields) {
		boolean r = searchWeightFieldsService.updateById(searchWeightFields);
		if (r) {
			return searchWeightFields;
		}
		return null;
	}

	@Override
	public void deleteSearchWeightFields(SearchWeightFields searchWeightFields) {
		boolean r = searchWeightFieldsService.deleteById(searchWeightFields
				.getId());
		if (r) {
			System.out.println("searchWeightFields 删除成功>>>"
					+ searchWeightFields.getId());
		}
	}

	@Override
	public SearchHotwords saveSearchHotwords(SearchHotwords searchHotwords) {
		boolean r = searchHotwordsService.insert(searchHotwords);
		if (r) {
			return searchHotwords;
		}
		return null;
	}

	@Override
	public SearchHotwords editSearchHotwords(SearchHotwords searchHotwords) {
		boolean r = searchHotwordsService.updateById(searchHotwords);
		if (r) {
			return searchHotwords;
		}
		return null;
	}

	@Override
	public void deleteSearchHotwords(SearchHotwords searchHotwords) {
		boolean r = searchHotwordsService.deleteById(searchHotwords.getId());
		if (r) {
			System.out.println("searchWeightFields 删除成功>>>"
					+ searchHotwords.getId());
		}
	}

	@Override
	public SearchHistory saveSearchHistory(SearchHistory searchHistory) {
		boolean r = searchHistoryService.insert(searchHistory);
		if (r) {
			return searchHistory;
		}
		return null;
	}

	@Override
	public void deleteSearchHistory(SearchHistory searchHistory) {
		boolean r = searchHistoryService.deleteById(searchHistory.getId());
		if (r) {
			System.out.println("searchHistory 删除成功>>>" + searchHistory.getId());
		}
	}

	@Override
	public void deleteSearchHistorys(List<Integer> ids) {
		boolean r = searchHistoryService.deleteBatchIds(ids);
		if (r) {
			System.out.println("searchHistorys 删除成功---数量>>>" + ids.size());
		}

	}

	@Override
	public SearchNotes saveSearchNotes(SearchNotes searchNotes) {
		boolean r = searchNotesService.insert(searchNotes);
		if (r) {
			return searchNotes;
		}
		return null;
	}

	@Override
	public SearchNotes editSearchNotes(SearchNotes searchNotes) {
		boolean r = searchNotesService.updateById(searchNotes);
		if (r) {
			return searchNotes;
		}
		return null;
	}

	@Override
	public void deleteSearchNotes(SearchNotes SearchNotes) {
		boolean r = searchNotesService.deleteById(SearchNotes.getId());
		if (r) {
			System.out.println("searchHistory 删除成功>>>" + SearchNotes.getId());
		}
	}

	@Override
	public IndexingWeights saveIndexingWeights(IndexingWeights indexingWeights) {
		boolean r = indexingWeightsService.insert(indexingWeights);
		if (r) {
			return indexingWeights;
		}
		return null;
	}

	@Override
	public IndexingWeights editIndexingWeights(IndexingWeights indexingWeights) {
		boolean r = indexingWeightsService.updateById(indexingWeights);
		if (r) {
			return indexingWeights;
		}
		return null;
	}

	@Override
	public void deleteIndexingWeights(IndexingWeights indexingWeights) {
		boolean r = indexingWeightsService.deleteById(indexingWeights.getId());
		if (r) {
			System.out.println("weightsService 删除成功>>>"
					+ indexingWeights.getId());
		}
	}

	@Override
	public IndexingRules saveIndexingRules(IndexingRules indexingRules) {
		boolean r = indexingRulesService.insert(indexingRules);
		if (r) {
			return indexingRules;
		}
		return null;
	}

	@Override
	public IndexingRules editIndexingRules(IndexingRules indexingRules) {
		boolean r = indexingRulesService.updateById(indexingRules);
		if (r) {
			return indexingRules;
		}
		return null;
	}

	@Override
	public void deleteIndexingRules(IndexingRules indexingRules) {
		boolean r = indexingRulesService.deleteById(indexingRules.getId());
		if (r) {
			System.out.println("indexingRules 删除成功>>>" + indexingRules.getId());
		}
	}

	@Override
	public NlpSensitiveWord saveNlpSensitiveWord(
			NlpSensitiveWord nlpSensitiveWord) {
		boolean r = nlpSensitiveWordService.insert(nlpSensitiveWord);
		if (r) {
			return nlpSensitiveWord;
		}
		return null;
	}

	@Override
	public NlpSensitiveWord editNlpSensitiveWord(
			NlpSensitiveWord nlpSensitiveWord) {
		boolean r = nlpSensitiveWordService.updateById(nlpSensitiveWord);
		if (r) {
			return nlpSensitiveWord;
		}
		return null;
	}

	@Override
	public void deleteNlpSensitiveWord(NlpSensitiveWord nlpSensitiveWord) {
		boolean r = nlpSensitiveWordService
				.deleteById(nlpSensitiveWord.getId());
		if (r) {
			System.out.println("nlpSensitiveWord 删除成功>>>"
					+ nlpSensitiveWord.getId());
		}
	}

	@Override
	public NlpStopWord saveNlpStopWord(NlpStopWord nlpStopWord) {
		boolean r = nlpStopWordService.insert(nlpStopWord);
		if (r) {
			return nlpStopWord;
		}
		return null;
	}

	@Override
	public NlpStopWord editNlpStopWord(NlpStopWord nlpStopWord) {
		boolean r = nlpStopWordService.updateById(nlpStopWord);
		if (r) {
			return nlpStopWord;
		}
		return null;
	}

	@Override
	public void deleteNlpStopWord(NlpStopWord nlpStopWord) {
		boolean r = nlpStopWordService.deleteById(nlpStopWord.getId());
		if (r) {
			System.out.println("nlpStopWord 删除成功>>>" + nlpStopWord.getId());
		}
	}

	@Override
	public SearchSubscribe saveSearchSubscribe(SearchSubscribe searchSubscribe) {
		boolean r = searchSubscribeService.insert(searchSubscribe);
		if (r) {
			return searchSubscribe;
		}
		return null;
	}

	@Override
	public SearchSubscribe editSearchSubscribe(SearchSubscribe searchSubscribe) {
		boolean r = searchSubscribeService.updateById(searchSubscribe);
		if (r) {
			return searchSubscribe;
		}
		return null;
	}

	@Override
	public void deleteSearchSubscribe(SearchSubscribe searchSubscribe) {
		boolean r = searchSubscribeService.deleteById(searchSubscribe.getId());
		if (r) {
			System.out.println("searchSubscribe 删除成功>>>"
					+ searchSubscribe.getId());
		}
	}

	@Override
	public DataBackup saveDataBackup(DataBackup dataBackup) {
		boolean r = dataBackupService.insert(dataBackup);
		if (r) {
			return dataBackup;
		}
		return null;
	}

	@Override
	public DataBackup editDataBackup(DataBackup dataBackup) {
		boolean r = dataBackupService.updateById(dataBackup);
		if (r) {
			return dataBackup;
		}
		return null;
	}

	@Override
	public void deleteDataBackup(DataBackup dataBackup) {
		boolean r = dataBackupService.deleteById(dataBackup.getId());
		if (r) {
			System.out
					.println("dataBackupService 删除成功>>>" + dataBackup.getId());
		}
	}

	@Override
	public DataRecovery saveDataRecovery(DataRecovery dataRecovery) {
		boolean r = dataRecoveryService.insert(dataRecovery);
		if (r) {
			return dataRecovery;
		}
		return null;
	}

	@Override
	public DataRecovery editDataRecovery(DataRecovery dataRecovery) {
		boolean r = dataRecoveryService.updateById(dataRecovery);
		if (r) {
			return dataRecovery;
		}
		return null;
	}

	@Override
	public void deleteDataRecovery(DataRecovery dataRecovery) {
		boolean r = dataRecoveryService.deleteById(dataRecovery.getId());
		if (r) {
			System.out.println("dataRecoveryService 删除成功>>>"
					+ dataRecovery.getId());
		}
	}

	@Override
	public ShardingDataSource saveShardingDataSource(
			ShardingDataSource shardingDataSource) {
		// TODO Auto-generated method stub
		boolean r = shardingDataSourceService.insert(shardingDataSource);
		if (r) {
			return shardingDataSource;
		}
		return null;
	}

	@Override
	public ShardingDataSource editShardingDataSource(
			ShardingDataSource shardingDataSource) {
		// TODO Auto-generated method stub
		boolean r = shardingDataSourceService
				.updateAllColumnById(shardingDataSource);
		if (r) {
			return shardingDataSource;
		}
		return null;
	}

	@Override
	public void deleteShardingDataSource(ShardingDataSource shardingDataSource) {
		// TODO Auto-generated method stub
		boolean r = shardingDataSourceService.deleteById(shardingDataSource
				.getId());
		if (r) {
			System.out.println("shardingDataSourceService 删除成功>>>"
					+ shardingDataSource.getId());
		}
	}

	@Override
	public ShardingRepositoryDataSource saveShardingRepositoryDataSource(
			ShardingRepositoryDataSource shardingRepositoryDataSource) {
		// TODO Auto-generated method stub
		boolean r = shardingRepositoryDataSourceService
				.insert(shardingRepositoryDataSource);
		if (r) {
			return shardingRepositoryDataSource;
		}
		return null;
	}

	@Override
	public ShardingRepositoryDataSource editShardingRepositoryDataSource(
			ShardingRepositoryDataSource shardingRepositoryDataSource) {
		// TODO Auto-generated method stub
		boolean r = shardingRepositoryDataSourceService
				.updateAllColumnById(shardingRepositoryDataSource);
		if (r) {
			return shardingRepositoryDataSource;
		}
		return null;
	}

	@Override
	public void deleteShardingRepositoryDataSource(
			ShardingRepositoryDataSource shardingRepositoryDataSource) {
		// TODO Auto-generated method stub
		boolean r = shardingRepositoryDataSourceService
				.deleteById(shardingRepositoryDataSource.getId());
		if (r) {
			System.out.println("shardingRepositoryDataSourceService 删除成功>>>"
					+ shardingRepositoryDataSource.getId());
		}
	}

	@Override
	public ShardingRepositoryCount saveShardingRepositoryCount(
			ShardingRepositoryCount shardingRepositoryCount) {
		// TODO Auto-generated method stub
		boolean r = shardingRepositoryCountService
				.insert(shardingRepositoryCount);
		if (r) {
			return shardingRepositoryCount;
		}
		return null;
	}

	@Override
	public ShardingRepositoryCount editShardingRepositoryCount(
			ShardingRepositoryCount shardingRepositoryCount) {
		// TODO Auto-generated method stub
		boolean r = shardingRepositoryCountService
				.updateAllColumnById(shardingRepositoryCount);
		if (r) {
			return shardingRepositoryCount;
		}
		return null;
	}

	@Override
	public void deleteShardingRepositoryCount(
			ShardingRepositoryCount shardingRepositoryCount) {
		// TODO Auto-generated method stub
		boolean r = shardingRepositoryCountService
				.deleteById(shardingRepositoryCount.getId());
		if (r) {
			System.out.println("shardingRepositoryCountService 删除成功>>>"
					+ shardingRepositoryCount.getId());
		}
	}
	
	@Override
	public MemberMessage saveMemberMessage(
			MemberMessage memberMessage) {
		// TODO Auto-generated method stub
		boolean r = memberMessageService
				.insert(memberMessage);
		if (r) {
			return memberMessage;
		}
		return null;
	}

	@Override
	public MemberMessage editMemberMessage(
			MemberMessage memberMessage) {
		// TODO Auto-generated method stub
		boolean r = memberMessageService
				.updateAllColumnById(memberMessage);
		if (r) {
			return memberMessage;
		}
		return null;
	}

	@Override
	public void deleteMemberMessage(
			MemberMessage memberMessage) {
		// TODO Auto-generated method stub
		boolean r = memberMessageService
				.deleteById(memberMessage.getId());
		if (r) {
			System.out.println("memberMessageService 删除成功>>>"
					+ memberMessage.getId());
		}
	}
	//
	@Override
	public SearchFavoriteCategory saveSearchFavoriteCategory(
			SearchFavoriteCategory searchFavoriteCategory) {
		// TODO Auto-generated method stub
		boolean r = searchFavoriteCategoryService
				.insert(searchFavoriteCategory);
		if (r) {
			return searchFavoriteCategory;
		}
		return null;
	}

	@Override
	public SearchFavoriteCategory editSearchFavoriteCategory(
			SearchFavoriteCategory searchFavoriteCategory) {
		// TODO Auto-generated method stub
		boolean r = searchFavoriteCategoryService
				.updateAllColumnById(searchFavoriteCategory);
		if (r) {
			return searchFavoriteCategory;
		}
		return null;
	}

	@Override
	public void deleteSearchFavoriteCategory(
			SearchFavoriteCategory searchFavoriteCategory) {
		// TODO Auto-generated method stub
		boolean r = searchFavoriteCategoryService
				.deleteById(searchFavoriteCategory.getId());
		if (r) {
			System.out.println("searchFavoriteCategoryService 删除成功>>>"
					+ searchFavoriteCategory.getId());
		}
	}
	
	//
	@Override
	public SearchFavoriteResource saveSearchFavoriteResource(
			SearchFavoriteResource searchFavoriteResource) {
		// TODO Auto-generated method stub
		boolean r = searchFavoriteResourceService
				.insert(searchFavoriteResource);
		if (r) {
			return searchFavoriteResource;
		}
		return null;
	}

	@Override
	public SearchFavoriteResource editSearchFavoriteResource(
			SearchFavoriteResource searchFavoriteResource) {
		// TODO Auto-generated method stub
		boolean r = searchFavoriteResourceService
				.updateAllColumnById(searchFavoriteResource);
		if (r) {
			return searchFavoriteResource;
		}
		return null;
	}

	@Override
	public void deleteSearchFavoriteResource(
			SearchFavoriteResource searchFavoriteResource) {
		// TODO Auto-generated method stub
		boolean r = searchFavoriteResourceService
				.deleteById(searchFavoriteResource.getId());
		if (r) {
			System.out.println("searchFavoriteResourceService 删除成功>>>"
					+ searchFavoriteResource.getId());
		}
	}

	@Override
	public Feedback saveFeedback(Feedback feedback) {
		boolean r = feedbackService
				.insert(feedback);
		if (r) {
			return feedback;
		}
		return null;
	}

	@Override
	public Feedback editFeedback(Feedback feedback) {
		boolean r = feedbackService
				.updateAllColumnById(feedback);
		if (r) {
			return feedback;
		}
		return null;
	}

	@Override
	public void deleteFeedback(Feedback feedback) {
		boolean r = feedbackService
				.deleteById(feedback.getId());
		if (r) {
			System.out.println("feedback 删除成功>>>"
					+ feedback.getId());
		}
		
	}
}
